<?php
require_once "a_config.php";
//开启session
if (!session_id()) {
    session_start();
}
//获取后台管理系统session_key
$session_key = $A_CONFIG['project_pre'] . 'admin_backstage';
$admin_status = $session_key . '_status';
$admin_name = $session_key . '_name';
if (isset($_SESSION[$admin_status])
    && $_SESSION[$admin_status] == "loginSuccess"
    && isset($_SESSION[$admin_name])
) {
    if (isset($_GET['action']) && $_GET['action'] = 'loginOut') {
        $_SESSION[$admin_status] = "";
        $_SESSION[$admin_name] = "";
        session_write_close();
        header("location:login.php");
        exit();
    } else {
        session_write_close();
        header("location:index.php");
        exit();
    }

}

?>
<!DOCTYPE html>
<html lang="en">
<head>

    <!-- start: Meta -->
    <meta charset="utf-8">
    <title><?php echo $A_CONFIG['backstage_name']; ?></title>
    <meta name="description" content="Bootstrap Metro Dashboard">
    <meta name="author" content="Dennis Ji">
    <meta name="keyword"
          content="Metro, Metro UI, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
    <!-- end: Meta -->

    <!-- start: Mobile Specific -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- end: Mobile Specific -->

    <!-- start: CSS -->
    <link id="bootstrap-style" href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/bootstrap-responsive.min.css" rel="stylesheet">
    <link id="base-style" href="css/style.css" rel="stylesheet">
    <link id="base-style-responsive" href="css/style-responsive.css" rel="stylesheet">
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800&subset=latin,cyrillic-ext,latin-ext'
          rel='stylesheet' type='text/css'>
    <!-- end: CSS -->


    <!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <link id="ie-style" href="css/ie.css" rel="stylesheet">
    <![endif]-->

    <!--[if IE 9]>
    <link id="ie9style" href="css/ie9.css" rel="stylesheet">
    <![endif]-->

    <!-- start: Favicon -->
    <link rel="shortcut icon" href="img/favicon.ico">
    <!-- end: Favicon -->

    <style type="text/css">
        body {
            background: url(img/bg-login-01.png) no-repeat  ;
			background-size:100vw 100vh
        }
	
		.login-box{
            border-radius: 10px;
			box-shadow: none;
		

		}
		
		
    </style>


</head>

<body>
<div class="container-fluid-full">
    <div class="row-fluid" >
          <img src="img/login-logo.png" style="width:300px;margin:10px 0 0 20px" >
	  <div  >  
	
        <div class="row-fluid" >
		  
            <div class="login-box" 	style="margin:100px auto;  ">
			 <img src="img/bg-login-02.png" style="position: absolute;z-index:-1;height:322px;margin:56px 0 0 75px">
                <div class="icons">

                </div>
                <h2 style="margin-left:48px;font-weight:bold;font-size:26px">紫金宿管后台管理系统</h2>
                <div class="form-horizontal">
                    <fieldset>

                        <div class="input-prepend" title="Username" >
                           
                            <input class="input-large span10" name="username" id="username" type="text" style="width:291px;height:34px;border:0px;border-radius: 17px;background-color:#F0F0F0; color: BBBBBB;text-indent: 10px"
                                   placeholder="管理员账号"/>
                        </div>
                        <div class="clearfix"></div>

                        <div class="input-prepend" title="Password" >
                       
                            <input class="input-large span10" name="password" id="password" type="password" style=";width:291px;height:34px;border:0px;border-radius: 50px;background-color:#F0F0F0; color: BBBBBB;text-indent: 10px"
                                   placeholder="密码"/>
                        </div>
                        <div class="clearfix"></div>

                        <!--							<label class="remember" for="remember"><input type="checkbox" id="remember" />Remember me</label>-->

                        <div class="button-login" style="text-align: center;margin:28px 33px 0 0">
                            <button id="login" class="" style="width:290px;height:34px;border:0px;border-radius: 17px;background-color:#71CEFA; color: white;letter-spacing: 6px;" >登录</button>
                        </div>
                        <div class="clearfix"></div>
                </div>
                <hr>

            </div><!--/span-->
        </div><!--/row-->
      </div>

    </div><!--/.fluid-container-->

</div><!--/fluid-row-->


<!-- start: JavaScript-->

<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/jquery-migrate-1.0.0.min.js"></script>

<script src="js/jquery-ui-1.10.0.custom.min.js"></script>

<script src="js/jquery.ui.touch-punch.js"></script>

<script src="js/modernizr.js"></script>

<script src="js/bootstrap.min.js"></script>

<script src="js/jquery.cookie.js"></script>

<script src='js/fullcalendar.min.js'></script>

<script src='js/jquery.dataTables.min.js'></script>

<script src="js/excanvas.js"></script>
<script src="js/jquery.flot.js"></script>

<script src="js/jquery.flot.pie.js"></script>
<script src="js/jquery.flot.stack.js"></script>
<script src="js/jquery.flot.resize.min.js"></script>

<script src="js/jquery.chosen.min.js"></script>

<script src="js/jquery.uniform.min.js"></script>

<script src="js/jquery.cleditor.min.js"></script>

<script src="js/jquery.noty.js"></script>

<script src="js/jquery.elfinder.min.js"></script>

<script src="js/jquery.raty.min.js"></script>

<script src="js/jquery.iphone.toggle.js"></script>

<script src="js/jquery.uploadify-3.1.min.js"></script>

<script src="js/jquery.gritter.min.js"></script>

<script src="js/jquery.imagesloaded.js"></script>

<script src="js/jquery.masonry.min.js"></script>

<script src="js/jquery.knob.modified.js"></script>

<script src="js/jquery.sparkline.min.js"></script>

<script src="js/counter.js"></script>

<script src="js/retina.js"></script>

<script src="js/custom.js"></script>


<?php
//引入两个弹窗
include 'myTip_js.html';

?>
<!-- end: JavaScript-->
<script>
    <?php
    $key = $A_CONFIG['api_key'];
    $unixtime = time();
    $token = md5($key . $unixtime);
    $token_info = "var token='{$token}',unixtime='{$unixtime}';";
    echo $token_info;
    ?>

    // $('#tip-modal').modal();
    $("#login").click(function () {
        var regSpace = /^\s+$/;
        if ($("#username").val() != "" && !regSpace.test($("#username").val()) &&
            $("#password").val() != "" && !regSpace.test($("#password").val())) {
            $.ajax({
                url: 'api/login/login.php',
                type: 'POST',
                data: {
                    token: token,
                    time: unixtime,
                    username: $("#username").val(),
                    password: $("#password").val()
                },
                dataType: 'JSON',
                error: function () {
                    MyAlert("请求超时");
                },
                success: function (res) {
                    //console.log(res);
                    if (res.err == 0) {
                        alert(res.msg);
                        window.location.href = "index.php";


                    } else {
                        MyAlert(res.msg);
                    }
                }
            })
        } else {
            MyAlert("请输入完整");
        }
    });


</script>
</body>
</html>
